<?php

App::uses('AppController', 'Controller');

class ReceptiController extends AppController {
	
	public $uses = array('Receipe');
	public $paginate = array( 'limit' => ITEMS_PER_PAGE );
	
	public function index() {
		$this->set("receipes", $this->paginate('Receipe'));
	}
	
	public function recept($id) {
		$this->breadcrumbsAdd("Recepti", '/recepti');
		
		$receipe = $this->Receipe->findById($id);
		$this->breadcrumbsAdd($receipe['Receipe']['title']);
		
		$related_receipes = $this->Receipe->find('all', array(
			'conditions' => array('Receipe.id !='=>$id)
		));
		
		$this->set(compact('receipe', 'related_receipes'));
	}
    
    public function stampa($id) {
        if (! $receipe = $this->Receipe->findById($id)) {
            $this->redirect('index');
        }
        
        $this->layout = 'print';
        $this->set(compact('receipe'));
    }
}
